package com.bw.house.controller;

import java.util.Arrays;
import java.util.Map;

import com.bw.house.entity.HouseImgsEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.bw.house.service.HouseImgsService;
import com.bw.common.utils.PageUtils;
import com.bw.common.utils.R;



/**
 * 图片表
 *
 * @author Hao_YunKai
 * @email 2745578447@qq.com
 * @date 2022-03-23 11:46:46
 */
@RestController
@RequestMapping("house/house-imgs")
public class HouseImgsController {
    @Autowired
    private HouseImgsService houseImgsService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = houseImgsService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Long id){
		HouseImgsEntity houseImgs = houseImgsService.getById(id);

        return R.ok().put("houseImgs", houseImgs);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody HouseImgsEntity houseImgs){
		houseImgsService.save(houseImgs);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody HouseImgsEntity houseImgs){
		houseImgsService.updateById(houseImgs);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] ids){
		houseImgsService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
